home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / lib232.zip / CAPCMD.SLT < prev    next >
Text File  |  1990-10-14  |  4KB  |  86 lines

  1. ////////////////////////////// CAPCMD.SLT ////////////////////////////////////
  2. //
  3. // DESCRIPTION:  This script is designed to be used in one of Custom Command
  4. // options of any Liberator Command File.  The script captures the results
  5. // of a user-defined PCBoard/ProDoor command to a user-defined file.
  6. //
  7. // INSTRUCTIONS:  Simply place the name of the capture file, along with the
  8. // command to send to PCBoard/ProDoor in Custom Command 1 or 2 in the follow-
  9. // ing format:
  10. //
  11. // @CapCmd <capfname> <command>
  12. //
  13. // To capture bulletin 6 to the file C:\TEMP\B6.CAP, the appropriate Custom
  14. // Command would be:
  15. //
  16. // @CapCmd C:\TEMP\B6.CAP B 6 NS
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. // Below are two things called 'variables', that I'm sure you've seen in other
  20. // scripts.  Once defined, they simply provide a place to store some numbers
  21. // (int) or letters (str) in memory, to be retrieved later.  If you have to
  22. // keep track of something in your scripts, just define variables as below.
  23. // int for numbers, str for 'strings' or groups of letters, symbols, etc.
  24. // the [64] means that the string can hold up to 64 characters.
  25.  
  26. int old_capture_stat;      // holds status of current capture file (open/closed)
  27. str old_capture_fname[64]; // holds name of current capture file
  28.  
  29. //////////////////////////////////////////////////////////////////////////////
  30. main(str fname, str cmd)
  31. {
  32.  if (not fname)              // check passed parameters, abort if none
  33.   return;                    // 'not fname' is TRUE if the str is empty
  34.  if (not cmd)
  35.   return;
  36.  
  37.  cputs(cmd);                 // send the passed cmd to the BBS
  38.  cputs("^M");                // along with a CR or <Enter>
  39.  
  40.  if (open_capture(fname))    // if open_capture() returns TRUE...
  41.   waitfor("Command? ", 300); // wait up to 5 minutes for a main prompt
  42.  
  43.  restore_capture();          // restore_capture() is defined below
  44. }
  45.  
  46. //////////////////////////////////////////////////////////////////////////////
  47. open_capture(str capfname)
  48. {
  49.  old_capture_stat = capture_stat();  // capture_stat() as explained in SALT dox
  50.  old_capture_fname = _capture_fname; // _capture_fname 'system variable' holds
  51.                                      // the name of the current capture file
  52.                                      // this stores the current name...
  53.  
  54.  _capture_fname = capfname;          // then replace with user-defined name
  55.  
  56.  if (capture_stat())                 // if capture file now open...
  57.   capture("*CLOSE*");                // close it...
  58.  
  59.  if (capture(_capture_fname) == -1)  // and try to open the new one
  60.   {
  61.    status_wind("Error opening capture file!", 30);
  62.    return(0);                        // return FALSE (zero) if error
  63.   }
  64.  
  65.  // the above if() may look a little strange, but what is means is:
  66.  // 'if() the return value of capture() is equal to (==) -1'.  The capture()
  67.  // function returns -1 when it can't open the specified _capture_fname, thus
  68.  // what's between the curly brackets gets executed 'if capture() returns -1'.
  69.  
  70.  return(1);                          // return TRUE (non-zero) if okay
  71. }
  72.  
  73. //////////////////////////////////////////////////////////////////////////////
  74. restore_capture()
  75. {
  76.  if (capture_stat())
  77.   capture("*CLOSE*");                // all done... close capture file
  78.  
  79.  _capture_fname = old_capture_fname; // put the old capture file name back
  80.                                      // (stored in open_capture() at start)
  81.  
  82.  if (old_capture_stat)               // if the capture file was open when we
  83.   capture(_capture_fname);           // started, then re-open it.
  84. }
  85.  
  86. //////////////////////////////////////////////////////////////////////////////